import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    component: () => import('@/views/Main.vue'),
    children: [
      {
        path: '/', name: 'Home', component: () => import('@/views/Home.vue')
      },
      {
        // props: true 所有在path里面的参数   都映射为组件的参数
        path: '/articles/:id', props: true, name: 'article', component: () => import('@/views/Article.vue')
      },
    ]
  },
  {
    path: '/heroes/:id', props: true, name: 'heroes', component: () => import('@/views/Hero.vue')
  },
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
